package world.snowcrystal.datasource;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Service;
import world.snowcrystal.model.entity.Picture;
import world.snowcrystal.service.PictureService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 图片服务实现类，用于抓取来自 <a href="www.bing.cn">bing</a> 的图片
 *
 * @author tianqing
 */
@Service
@ConditionalOnBean(PictureService.class)
public class BingPictureDataSource extends PictureDataSource {

    @Resource
    private PictureService pictureService;

    @Override
    public Page<Picture> doSearch(String searchText, long pageNum, long pageSize, HttpServletRequest request) {
        return pictureService.searchPicture(searchText, pageNum, pageSize);
    }

    @Override
    boolean isDataSourceAvailable() {
        return true;
    }

}